import 'dart:ui';

import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/localizations.dart';
import 'package:reabampos/src/reabam/operation/rb_config.dart';
import 'package:reabampos/src/reabam/operation/rb_enum.dart';
import 'package:reabampos/src/reabam/utils/rb_color.dart';
import 'package:xsdk_flutter/xsdk/framework/x_app.dart';
import 'package:xsdk_flutter/xsdk/xsdk_flutter_package.dart';
import 'reabam/pagestate_welcome.dart';

/*
润之河开发者模式
打开桌面的计算器，输入38259016=
 */
class MyApp extends XSDKApp {
  MyApp(
      {super.key,
      super.titleName,
      super.appRunInBackgroundAutoRestartHours = 2});

  @override
  Widget initFirstPage() {
    if (XFlutterUtils.isiOS()) {
      return XPage(() => WelcomeStatePage(milliseconds: 1000));
    } else {
      return XPage(() => WelcomeStatePage(milliseconds: 2000));
    }
  }

  @override
  void initData() async {
    //自助收银
    if (RBConfigs.versionType == VersionType.officialSelfServiceVersion ||
        RBConfigs.versionType == VersionType.testSelfServiceVersion) {
      //
      XColorUtils.dividerColor = const Color(0xFFE6E6E6);
      XTempData.defaultDividerHeight = 2;
      XTempData.isResizeToAvoidBottomInset = false;
      XTempData.defaultTitleFontSize = 34;
      XTempData.defaultTextFontSize = 30;
      XTempData.defaultSmallTextFontSize = 26;
      XTempData.defaultMiniTextFontSize = 22;

      XTempData.defaultSwitchWidth = 90;
      XTempData.defaultSwitchHeight = 60;
      XTempData.defaultRadioWidth = 65;
      XTempData.defaultRadioHeight = 65;
      XTempData.defaultCheckboxWidth = 65;
      XTempData.defaultCheckboxHeight = 65;

      XTempData.defaultBottomBarHeight = 260;
      XTempData.defaultBottomRadius = 16;
      XTempData.defaultBottomHeight = 120;
      XTempData.defaultButtonFontSize = 46;
      RBConfigs.bottomBarButtomMarginLeftRight = 90;

      XTempData.defaultLeftKeyWidth = 200;

      XTempData.defaultPageMarginLeft = 30;
      XTempData.defaultPageMarginRight = 30;
      XTempData.defaultLeftRightWidgetMarginLeft = 30;
      XTempData.defaultLeftRightWidgetMarginRight = 30;

      RBConfigs.selectImageWidth = 50;
      RBConfigs.image_nav_arrow_right_width = 16;
      RBConfigs.image_nav_arrow_right_height = 28;

      XTempData.defaultBarHeight = 120;
      RBConfigs.deviceBarHeight = 150;

      RBConfigs.dialogWidth = 980;

      XTempData.defaultLoadingWidgetWidthHeight = 48;
      XTempData.defaultLoadingWidgetStrokeWidth = 4;

      XColorUtils.appMainColor = RBColors.reabamColor4;

      //
      if (RBConfigs.versionType == VersionType.officialSelfServiceVersion) {
        //自助收银正式版
        RBConfigs.apiUrl = 'https://pos.reabam.com';
      } else if (RBConfigs.versionType == VersionType.testSelfServiceVersion) {
        //自助收银测试版
        RBConfigs.apiUrl = 'http://fat-pos.reabam.com:58090';
      }
    }
  }

  @override
  List<LocalizationsDelegate>? getLocalizationsDelegates() {
    return null;
  }

  @override
  List<Locale>? getSupportedLocales() {
    return null;
  }
}
